#include <bits/stdc++.h>
using namespace std;

struct node {
	int id, k;
	int level;
	vector<int> child;
	node(int i = 0, int l = 0, int k = 0) :level(l), id(i), k(k) {};
};

vector<node> tree;
queue<int> que;
vector<int> ans;

void bfs() {
	int now = 1;
	que.push(now);
	int level = 1;
	int cnt = 0;
	while (!que.empty()) {
		int top = que.front();
		que.pop();
		if (tree[top].level == level) {
			level++;
			ans.push_back(cnt);
			cnt = 0;
		}
		if (tree[top].k) {
			for (auto it = tree[top].child.begin(); it != tree[top].child.end(); ++it) {
				que.push(*it);
				tree[*it].level = level;
			}
		}
		else {
			cnt++;
		}
	}

	ans.push_back(cnt);
	return;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	tree.resize(n + 1);
	for (int i = 0; i < m; ++i) {
		int id, k;
		scanf("%d%d", &id, &k);
		tree[id].child.resize(k);
		tree[id].k = k;
		for (int j = 0; j < k; ++j) {
			scanf("%d", &tree[id].child[j]);
		}
	}

	bfs();

	for (auto it = ans.begin(); it != ans.end(); ++it) {
		if (it != ans.begin())
			printf(" ");
		printf("%d", *it);
	}
	return 0;
}